package com.lx.mobileplayer.utils

import android.app.Activity
import android.content.DialogInterface
import android.support.v7.app.AlertDialog
import java.lang.IllegalArgumentException

/**
 * 类说明：弹出AlertDialog的工具类
 * Created by liuxiong on 2019/4/27.
 */
object AlertDialogUtil {

    fun showDialog(
        activity: Activity?,
        title:String="",
        message:String,
        cancelable:Boolean=true,
        negativeButtonText:String="",
        cancelListener: DialogInterface.OnClickListener?=null,
        positiveButtonText:String,
        positivewListener: DialogInterface.OnClickListener){


        if(activity==null){
            throw IllegalArgumentException("activity can not be null ")
        }

        AlertDialog.Builder(activity)
            .setTitle(title)
            .setMessage(message)
            .setCancelable(cancelable)
            .setNegativeButton(negativeButtonText,cancelListener)
            .setPositiveButton(positiveButtonText,positivewListener)
            .show()
    }
}